<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>
            // ES6 之前写法 —— 若 b 为null, 则默认值为 1
            function add(a,b){
                b = b | 1;
                return a + b;
            }
            console.log(add(10));

            // ES6 之后，自己赋值一个默认值
            function add2(a, b=1) {
                return a + b;
            }
            console.log(add2(20));
            
            // 不定参数
            function fun(...values){
                console.log(values.length)
            }
            fun(1, 2);
            fun(1, 2, 3);

            // 箭头函数
            var print = obj => console.log(obj);

            print("hello")

            var addAB = (a, b) => a + b;

            console.log(addAB(1, 2))

            var sum3 = (a, b) => {
                c = a + b;
                return a + c;
            }

            console.log(sum3(10, 20));

            const person = {
                name: "wangqing",
                love: "java"
            }
            function hello(person) {
                console.log("hello" + person.name)
                console.log(person.name + "like" + person.love)
            }

            hello(person);

            var hello2 = ({name, love}) => {
                console.log("hello" + name)
                console.log(name + "like" + love)
            }
            hello2(person);

    
    </script>


</body>
</html>